import React from 'react'
import { useLocation, useNavigate } from 'react-router-dom'

function Index({ children }) {
    function Com() {
        const navigate = useNavigate()
        const token = localStorage.getItem('token')
        // const { pathname } = useLocation()
        // const WhileList = ['/register','/login']
        if(!token){
            navigate('/login')
        }
        return children
    }
    return <Com></Com>
}

export default Index
